package com.wps.www;

import java.util.Arrays;

public class Main {
    public static void func(int arr[]){
        if(arr==null&&arr.length==0){
            return;
        }
        int left=0;
        int right= arr.length-1;
        while(left<right){
            while(left<right&&(arr[left]%2!=0)){
                left++;
            }
            while (left<right&&arr[right]%2==0){
                right--;
            }
            if (left<right){
                int tmp=arr[left];
                arr[left]=arr[right];
                arr[right]=tmp;
            }
        }
    }
    public static void main(String[] args) {
        int []arr={1,2,3,4,5,6,7,8,9};
        func(arr);
        for (int x:arr){
            System.out.print(" "+x);
        }
    }
}
